home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OCFSRC.PAK / OCVIEW.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  32KB  |  1,507 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectComponents
  3. // Copyright (c) 1994, 1997 by Borland International, All Rights Reserved
  4. //
  5. // $Revision:   2.15  $
  6. //
  7. // Implementation of TOcView Class
  8. //----------------------------------------------------------------------------
  9. #include <ocf/pch.h>
  10. #if !defined(OCF_OLEUTIL_H)
  11. # include <ocf/oleutil.h>
  12. #endif
  13. #if !defined(OCF_OCSTORAG_H)
  14. # include <ocf/ocstorag.h>
  15. #endif
  16. #if !defined(OCF_OCVIEW_H)
  17. # include <ocf/ocview.h>
  18. #endif
  19. #if !defined(OCF_OCREMVIE_H)
  20. # include <ocf/ocremvie.h>
  21. #endif
  22. #if !defined(OCF_OCAPP_H)
  23. # include <ocf/ocapp.h>
  24. #endif
  25. #if !defined(OCF_OCPART_H)
  26. # include <ocf/ocpart.h>
  27. #endif
  28. #if !defined(OCF_OCDATA_H)
  29. # include <ocf/ocdata.h>
  30. #endif
  31. #if !defined(OCF_AUTODEFS_H)
  32. # include <ocf/autodefs.h>
  33. #endif
  34. #if !defined(SERVICES_MEMORY_H)
  35. # include <services/memory.h>
  36. #endif
  37. #if !defined(WINSYS_LCLSTRNG_H)
  38. # include <winsys/lclstrng.h>
  39. #endif
  40. #if !defined(WINSYS_GEOMETRY_H)
  41. # include <winsys/geometry.h>
  42. #endif
  43.  
  44. DIAG_DECLARE_GROUP(OcRefCount);
  45.  
  46. const char  DocContent[] = "All";
  47.  
  48. //
  49. // Compatibility constructor
  50. //
  51. TOcView::TOcView(TOcDocument& doc, TRegList* regList, IUnknown* outer)
  52. :
  53.   OcApp(doc.OcApp),
  54.   OcDocument(doc),
  55.   ContainerHost(new TOcContainerHostMsg),
  56.   ServerHost(new TOcServerHostMsg),
  57.   ActivePart(0),
  58.   LinkFormat(-1),
  59.   RegList(regList),
  60.   OcData(0),
  61.   Options(0),
  62. #if defined(BI_DATA_NEAR)
  63.   WinTitle(*new string),
  64.   Origin(*new TPoint(0,0)),
  65.   Extent(*new TSize(0,0)),
  66.   FormatList(*new TOcFormatList),
  67.   OrgTitle(*new TString),
  68. #else
  69.   Origin(0,0),
  70.   Extent(0,0),
  71. #endif
  72.   BContainer(0),
  73.   BDocumentI(0),
  74.   BDocument(0),
  75.   BLDocumentI(0)
  76. {
  77.   SetOuter(outer);
  78.   AddRef();    // TUnknown defaults to 0, we need 1
  79.   if (regList)
  80.     RegisterClipFormats(*regList);
  81.  
  82.   // Necessary to initialize TOcPart for linking
  83.   //
  84.   OcDocument.SetActiveView(this);
  85.  
  86.   if (SUCCEEDED(OcApp.BOleComponentCreate(&BDocument,
  87.                 (IUnknown*)(IBContainer*)this, cidBOleDocument))) {
  88.     BDocument->QueryInterface(IID_IBDocument, &(LPVOID)BDocumentI);
  89.     Release();
  90.   }
  91.  
  92.   if (SUCCEEDED(OcApp.BOleComponentCreate(&BContainer,
  93.                 (IUnknown*)(IBContainer*)this, cidBOleContainer))) {
  94.     if (regList) {
  95.       const char* progid = regList->Lookup(OcApp.IsOptionSet(amDebug) ?
  96.                                            "debugprogid" : "progid");
  97.       if (progid &&
  98.           SUCCEEDED(BContainer->QueryInterface(IID_IBRootLinkable, &(LPVOID)BLDocumentI))) {
  99.         Release();
  100.         BLDocumentI->Init((TOcView*)this, OleStr(progid));
  101.       }
  102.     }
  103.   }
  104.  
  105.   TRACEX(OcRefCount, 1, "TOcView() @" << (void*)this);
  106. }
  107.  
  108. //
  109. // New, interface constructor
  110. //
  111. TOcView::TOcView(TOcDocument& doc, TOcContainerHost* ch, TOcServerHost* sh,
  112.                  TRegList* regList, IUnknown* outer)
  113. :
  114.   OcApp(doc.OcApp),
  115.   OcDocument(doc),
  116.   ContainerHost(ch),
  117.   ServerHost(sh),
  118.   ActivePart(0),
  119.   LinkFormat(-1),
  120.   RegList(regList),
  121.   OcData(0),
  122.   Options(0),
  123. #if defined(BI_DATA_NEAR)
  124.   WinTitle(*new string),
  125.   Origin(*new TPoint(0,0)),
  126.   Extent(*new TSize(0,0)),
  127.   FormatList(*new TOcFormatList),
  128.   OrgTitle(*new TString),
  129. #else
  130.   Origin(0,0),
  131.   Extent(0,0),
  132. #endif
  133.   BContainer(0),
  134.   BDocumentI(0),
  135.   BDocument(0),
  136.   BLDocumentI(0)
  137. {
  138.   SetOuter(outer);
  139.   AddRef();    // TUnknown defaults to 0, we need 1
  140.   if (regList)
  141.     RegisterClipFormats(*regList);
  142.  
  143.   // Necessary to initialize TOcPart for linking
  144.   //
  145.   OcDocument.SetActiveView(this);
  146.  
  147.   if (SUCCEEDED(OcApp.BOleComponentCreate(&BDocument,
  148.                 (IUnknown*)(IBContainer*)this, cidBOleDocument))) {
  149.     BDocument->QueryInterface(IID_IBDocument, &(LPVOID)BDocumentI);
  150.     Release();
  151.   }
  152.  
  153.   if (SUCCEEDED(OcApp.BOleComponentCreate(&BContainer,
  154.                 (IUnknown*)(IBContainer*)this, cidBOleContainer))) {
  155.     if (regList) {
  156.       const char* progid = regList->Lookup(OcApp.IsOptionSet(amDebug) ?
  157.                                            "debugprogid" : "progid");
  158.       if (progid &&
  159.           SUCCEEDED(BContainer->QueryInterface(IID_IBRootLinkable, &(LPVOID)BLDocumentI))) {
  160.         Release();
  161.         BLDocumentI->Init((TOcView*)this, OleStr(progid));
  162.       }
  163.     }
  164.   }
  165.  
  166.   TRACEX(OcRefCount, 1, "TOcView() @" << (void*)this);
  167. }
  168.  
  169. //
  170. //
  171. //
  172. TOcView::~TOcView()
  173. {
  174.   Shutdown();
  175. #if defined(BI_DATA_NEAR)
  176.   delete &WinTitle;
  177.   delete &FormatList;
  178.   delete &Origin;
  179.   delete &Extent;
  180.   delete &OrgTitle;
  181. #endif
  182. }
  183.  
  184. //
  185. // Called from destructor of this class or of derived class to release helpers
  186. // & host interfaces
  187. //
  188. void
  189. TOcView::Shutdown()
  190. {
  191.   if (BContainer) {
  192.     BContainer->Release();
  193.     BContainer = 0;
  194.   }
  195.   if (BDocument) {
  196.     BDocument->Release();
  197.     BDocument = 0;
  198.   }
  199.   if (ContainerHost) {
  200.     ContainerHost->ReleaseOcObject();
  201.     ContainerHost = 0;
  202.   }
  203.   if (ServerHost) {
  204.     ServerHost->ReleaseOcObject();
  205.     ServerHost = 0;
  206.   }
  207. }
  208.  
  209. //
  210. // Should only be called by the owner/creator of this object. Releases host
  211. // interfaces & this.
  212. //
  213. void
  214. TOcView::ReleaseObject()
  215. {
  216.   if (ContainerHost) {
  217.     ContainerHost->ReleaseOcObject();
  218.     ContainerHost = 0;
  219.   }
  220.   if (ServerHost) {
  221.     ServerHost->ReleaseOcObject();
  222.     ServerHost = 0;
  223.   }
  224.   Release();
  225. }
  226.  
  227. //
  228. // Callback from TUnknown's implementation of QueryInterface
  229. //
  230. HRESULT
  231. TOcView::QueryObject(const IID far& iid, void far* far* iface)
  232. {
  233.   PRECONDITION(iface);
  234.   HRESULT hr;
  235.  
  236.   // interfaces
  237.   //
  238.      SUCCEEDED(hr = IBContainer_QueryInterface(this, iid, iface))
  239.   || SUCCEEDED(hr = IBContains_QueryInterface(this, iid, iface))
  240.   || SUCCEEDED(hr = IBDataConsumer_QueryInterface(this, iid, iface))
  241.   || SUCCEEDED(hr = IBDropDest_QueryInterface(this, iid, iface))
  242.   || SUCCEEDED(hr = IBDataNegotiator_QueryInterface(this, iid, iface))
  243.  
  244.   // helpers (BContainer needed for embed/link from file)
  245.   //
  246.   || (BContainer && SUCCEEDED(hr = BContainer->QueryInterface(iid, iface)))
  247.   || (BDocument && SUCCEEDED(hr = BDocument->QueryInterface(iid, iface)))
  248.   ;
  249.  
  250.   // If the QueryInterface failed, try the TOcLinkView
  251.   //
  252.  
  253.   if (hr == HR_NOINTERFACE && iid == IID_IDataObject) {
  254.     TOcLinkView* view = GetDocLink(0);
  255.     if (view)
  256.       hr = view->QueryInterface(iid, iface);
  257.   }
  258.  
  259.   return hr;
  260. }
  261.  
  262. //----------------------------------------------------------------------------
  263.  
  264. //
  265. //
  266. //
  267. void
  268. TOcView::SetupWindow(HWND hWin, bool embedded)
  269. {
  270.   // Don't register drag&drop target here since it will do QueryInterface
  271.   // in ComponentCreate before the outer is set up. RefCount will be messed
  272.   // up in this case. Keep Win==0 while initing BDocumentI. OcRemView will init
  273.   // later.
  274.   //
  275.   if (!embedded) {
  276.     ContainerHost->SetWindow(hWin);
  277.     ServerHost->SetWindow(hWin);
  278.   }
  279.  
  280.   // Make sure at least the BDocument gets its container & application ptrs
  281.   // setup
  282.   //
  283.   if (BDocumentI)
  284.     BDocumentI->Init(this);
  285.  
  286.   if (!embedded)
  287.     Rename();
  288.  
  289.   // Now keep window handle if embedded
  290.   //
  291.   if (embedded) {
  292.     ContainerHost->SetWindow(hWin);
  293.     ServerHost->SetWindow(hWin);
  294.   }
  295.  
  296.   EvActivate(true);    // Default to being the active view on creation
  297. }
  298.  
  299. //
  300. // Obtain a TOcLinkView representing a moniker, the whole document by default
  301. //
  302. TOcLinkView*
  303. TOcView::GetDocLink(const char far* name)
  304. {
  305.   // Default to the whole document contents
  306.   //
  307.   if (!name)
  308.     name = DocContent;
  309.  
  310.   TOcViewCollection& views = OcDocument.GetViews();
  311.  
  312.   // Ask the document whether an TOcLinkView corresponding to the item name
  313.   // already exists
  314.   //
  315.   TOcLinkView* ocLinkView = views.Find(name);
  316.  
  317.   // If not, Create an TOcLinkView for the linked doc/item the TOcLinkView
  318.   // should remember the moniker. If the host does not accept the link,
  319.   // then get rid of the linkview & return nothing.
  320.   //
  321.   if (!ocLinkView) {
  322.     ocLinkView = new TOcLinkView(this, RegList);
  323.     views.Add(ocLinkView);
  324.  
  325.     ocLinkView->SetMoniker(OleStr(name));
  326.     ocLinkView->GetLinkRect();
  327.  
  328.     CHECK(ServerHost);
  329.     if (!ServerHost->EvOcViewSetLink(*ocLinkView)) {
  330.       views.Detach(ocLinkView, true);
  331.       return 0;
  332.     }
  333.   }
  334.  
  335.   return ocLinkView;
  336. }
  337.  
  338. //
  339. //
  340. //
  341. void
  342. TOcView::EvResize()
  343. {
  344.   if (BDocumentI)
  345.     BDocumentI->OnResize();
  346. }
  347.  
  348. //
  349. // View is shuting down
  350. //
  351. void
  352. TOcView::EvClose()
  353. {
  354.   // Release the data provider object
  355.   //
  356.   if (OcData) {
  357.     OcData->Disconnect();
  358.     OcData = 0;
  359.   }
  360.  
  361.   if (BContainer && BDocument && BDocumentI) {
  362.     // Unregisters drag target
  363.     //
  364.     BDocumentI->OnClose();
  365.  
  366.     // Unregisters moniker for this container
  367.     //
  368.     if (BLDocumentI)
  369.       BLDocumentI->OnRename(0, 0);
  370.   }
  371. }
  372.  
  373. //
  374. // View is activated/deactivated
  375. //
  376. void
  377. TOcView::EvActivate(bool activate)
  378. {
  379.   // Set the current active document
  380.   //
  381.   if (BDocumentI)
  382.     BDocumentI->OnActivate(activate);
  383.   if (activate)
  384.     OcDocument.SetActiveView(this);
  385. }
  386.  
  387. //
  388. // Returns true if view keeps focus, false if the inplace server got it
  389. //
  390. bool
  391. TOcView::EvSetFocus(bool set)
  392. {
  393.   if (BDocumentI)
  394.     BDocumentI->OnSetFocus(set);
  395.  
  396.   return OcApp.EvSetFocus(set);
  397. }
  398.  
  399. //
  400. //
  401. //
  402. bool
  403. TOcView::EnumLinks(IBLinkInfo far* far* linkInfo)
  404. {
  405.   PRECONDITION(linkInfo);
  406.  
  407.   return BDocumentI ? HRSucceeded(BDocumentI->EnumLinks(linkInfo)) : false;
  408. }
  409.  
  410. //
  411. //
  412. //
  413. bool
  414. TOcView::BrowseLinks()
  415. {
  416.   return BDocumentI ? HRSucceeded(BDocumentI->BrowseLinks()) : false;
  417. }
  418.  
  419. //
  420. //
  421. //
  422. bool
  423. TOcView::UpdateLinks()
  424. {
  425.   return BDocumentI ? HRSucceeded(BDocumentI->UpdateLinks()) : false;
  426. }
  427.  
  428. //
  429. //
  430. //
  431. void
  432. TOcView::Rename()
  433. {
  434.   if (!BLDocumentI || OcDocument.GetName().is_null())
  435.     return;
  436.  
  437.   // update the file moniker
  438.   //
  439.   BLDocumentI->OnRename(0, OleStr(OcDocument.GetName().c_str()));
  440.  
  441.   OcDocument.RenameParts(BLDocumentI);
  442. }
  443.  
  444. //----------------------------------------------------------------------------
  445.  
  446. //
  447. // Return the client rect for the view window
  448. //
  449. TRect
  450. TOcView::GetWindowRect() const
  451. {
  452.   TRect r;
  453.   const_cast<TOcView*>(this)->GetWindowRect(&r);
  454.   return r;
  455. }
  456.  
  457. //
  458. // Scroll this container window a give dx,dy
  459. //
  460. void
  461. TOcView::ScrollWindow(int dx, int dy)
  462. {
  463.   Origin += TPoint(dx, dy);
  464. }
  465.  
  466. void
  467. TOcView::InvalidatePart(TOcPartChangeInfo& changeInfo)
  468. {
  469.   if (changeInfo.GetPart()) {
  470.     CHECK(ContainerHost);
  471.     if (!ContainerHost->EvOcPartInvalid(changeInfo))
  472.       ::InvalidateRect(GetWindow(),
  473.                        &(changeInfo.GetPart()->GetRect() - *(TSize*)&GetOrigin()),
  474.                        true);
  475.   }
  476. }
  477.  
  478. //
  479. // Activate a given part
  480. //
  481. bool
  482. TOcView::ActivatePart(TOcPart* part)
  483. {
  484.   if (part == ActivePart)
  485.     return true;
  486.  
  487.   if (ActivePart && ActivePart->IsActive()) {
  488.     ActivePart->Activate(false);
  489.     ActivePart = 0;
  490.   }
  491.   if (part) {
  492.     if (!part->IsActive() && !part->Activate(true))
  493.       return false;
  494.     ActivePart = part;
  495.   }
  496.   return true;
  497. }
  498.  
  499. /*
  500. //
  501. //
  502. //
  503. uint32
  504. TOcView::ForwardEvent(int eventId, const void far* param)
  505. {
  506.   return ::SendMessage(GetWindow(), WM_OCEVENT, eventId, (LPARAM)param);
  507. }
  508.  
  509. //
  510. //
  511. //
  512. uint32
  513. TOcView::ForwardEvent(int eventId, uint32 param)
  514. {
  515.   return ::SendMessage(GetWindow(), WM_OCEVENT, eventId, param);
  516. }
  517. */
  518.  
  519. //----------------------------------------------------------------------------
  520. // IBContains implementation
  521.  
  522. //
  523. // Ask the container to load document named 'path'
  524. //
  525. HRESULT _IFUNC
  526. TOcView::Init(LPCOLESTR path)
  527. {
  528.   CHECK(ContainerHost);
  529.   bool result = ContainerHost->EvOcViewOpenDoc(OleStr(path));
  530.   if (result) {
  531.  
  532.     // Register this document in running object table
  533.     //
  534.     OcDocument.SetName(string(OleStr(path)));
  535.     Rename();
  536.   }
  537.  
  538.   return HRFailIfZero(result);
  539. }
  540.  
  541. //
  542. //
  543. //
  544. HRESULT _IFUNC
  545. TOcView::GetPart(IBPart far* far* bpart, LPCOLESTR name)
  546. {
  547.   PRECONDITION(bpart);
  548.  
  549.   for (TOcPartCollectionIter i(OcDocument.GetParts()); i; i++) {
  550.     TOcPart* ocPart = (TOcPart*)i.Current();
  551.     if (ocPart && strcmp(ocPart->GetName(), OleStr(name)) == 0) {
  552.       ocPart->FinishLoading();  // In case the part hasn't been loaded
  553.       if (SUCCEEDED(ocPart->QueryInterface(IID_IBPart, (LPVOID*)bpart))) {
  554.         return HR_NOERROR;      // Now there is one more refcount on ocPart
  555.       }
  556.     }
  557.   }
  558.  
  559.   // Ask the document whether an TOcLinkView corresponding to the item name
  560.   // already exists. Create one automatically if needed & let host know.
  561.   //
  562.   TOcLinkView* ocLinkView = GetDocLink(OleStr(name));
  563.  
  564.   if (ocLinkView) {
  565.     if (SUCCEEDED(ocLinkView->QueryInterface(IID_IBPart, (LPVOID*)bpart)))
  566.       return HR_NOERROR; // Now there is one more refcount on ocRemView 
  567.     else
  568.       return HR_FAIL;  // This should never happen--its our own link view...
  569.   }
  570.  
  571.   return HR_FAIL;
  572. }
  573.  
  574. //----------------------------------------------------------------------------
  575. // IBDataNegotiator implementation
  576.  
  577. //
  578. // Format count
  579. //
  580. uint _IFUNC
  581. TOcView::CountFormats()
  582. {
  583.   return FormatList.Count();
  584. }
  585.  
  586. //
  587. // Format retrieval
  588. //
  589. HRESULT _IFUNC
  590. TOcView::GetFormat(uint index, TOcFormatInfo far* fmt)
  591. {
  592.   PRECONDITION(fmt);
  593.  
  594.   // Link source is FormatList[0]
  595.   // Link source will be the first format returned if Link is 0
  596.   // Link source will be the last format returned if Link is -1
  597.   //
  598.   index = (index - LinkFormat) % CountFormats();
  599.   FormatList[index]->GetFormatInfo(*fmt);
  600.   return HR_NOERROR;
  601. }
  602.  
  603. //----------------------------------------------------------------------------
  604. // IBWindow implementation
  605.  
  606. //
  607. //
  608. //
  609. HWND _IFUNC
  610. TOcView::GetWindow()
  611. {
  612.   return ContainerHost->EvOcGetWindow();
  613. }
  614.  
  615. //
  616. //
  617. //
  618. HRESULT _IFUNC
  619. TOcView::GetWindowRect(TRect far* r)
  620. {
  621.   PRECONDITION(r);
  622.  
  623.   ::GetClientRect(GetWindow(), r);
  624.   return HR_NOERROR;
  625. }
  626.  
  627. //
  628. //
  629. //
  630. LPCOLESTR _IFUNC
  631. TOcView::GetWindowTitle()
  632. {
  633.   // Delegate to app's view window to get its title
  634.   //
  635.   OrgTitle = ContainerHost->EvOcViewTitle();
  636.   return (LPCOLESTR)OrgTitle;
  637. }
  638.  
  639. //
  640. // Append server's doc title info to our view's window title
  641. //
  642. void _IFUNC
  643. TOcView::AppendWindowTitle(LPCOLESTR title)
  644. {
  645.   WinTitle = (const char far*)OleStr(GetWindowTitle());
  646.   char in[32];
  647.   ::LoadString(_hInstance, IDS_IN, in, sizeof in);
  648.  
  649.   string newTitle = (const char far*)OleStr(title);
  650.   newTitle += in;
  651.   newTitle += WinTitle;
  652.  
  653.   ContainerHost->EvOcViewSetTitle(newTitle.c_str());
  654. }
  655.  
  656. //
  657. //
  658. //
  659. HRESULT _IFUNC
  660. TOcView::SetStatusText(LPCOLESTR /*text*/)
  661. {
  662.   return HR_FAIL;  // Not called on BOle sites
  663. }
  664.  
  665. //
  666. //
  667. //
  668. HRESULT _IFUNC
  669. TOcView::RequestBorderSpace(const TRect far* space)
  670. {
  671.   PRECONDITION(space);
  672.  
  673.   // Let individual views decide this
  674.   //
  675.   return HRFailIfZero(ContainerHost->EvOcViewBorderSpaceReq(space));
  676. }
  677.  
  678. //
  679. //
  680. //
  681. HRESULT _IFUNC
  682. TOcView::SetBorderSpace(const TRect far* space)
  683. {
  684.   PRECONDITION(space);
  685.  
  686.   // Let individual views do this
  687.   //
  688.   return HRFailIfZero(ContainerHost->EvOcViewBorderSpaceSet(space));
  689. }
  690.  
  691. //
  692. //
  693. //
  694. HRESULT _IFUNC
  695. TOcView::InsertContainerMenus(HMENU, TOcMenuWidths far*)
  696. {
  697.   return HR_FAIL;  
  698. }
  699.  
  700. //
  701. //
  702. //
  703. HRESULT _IFUNC
  704. TOcView::SetFrameMenu(HMENU)
  705. {
  706.   return HR_FAIL;  
  707. }
  708.  
  709. //
  710. // The in-place server is done. Tell the container to restore its normal UI.
  711. //
  712. void _IFUNC
  713. TOcView::RestoreUI()
  714. {
  715.   ContainerHost->EvOcViewSetTitle(WinTitle.c_str());
  716. }
  717.  
  718. //
  719. //
  720. //
  721. HRESULT _IFUNC
  722. TOcView::Accelerator(MSG far*)
  723. {
  724.   return HR_FAIL;  
  725. }
  726.  
  727. //
  728. //
  729. //
  730. HRESULT _IFUNC
  731. TOcView::GetAccelerators(HACCEL far*, int far*)
  732. {
  733.   return HR_FAIL;  
  734. }
  735.  
  736. //----------------------------------------------------------------------------
  737. // IBDropDest implementation
  738.  
  739. //
  740. // Drop a part onto this view. Creates the part based on initInfo, activating
  741. // it as appropriate
  742. //
  743. HRESULT _IFUNC
  744. TOcView::Drop(TOcInitInfo far* initInfo, TPoint far* where, const TRect far* objPos)
  745. {
  746.   PRECONDITION(initInfo && where && objPos);
  747.  
  748.   initInfo->Container = this;
  749.   TPoint awhere(*where);
  750.   TRect  aobjPos(*objPos);
  751.   TOcDragDrop dd = {
  752.     (TOcInitInfo far*)initInfo, &awhere, &aobjPos
  753.   };
  754.  
  755.   if (PasteNative((TOcInitInfo&)*initInfo, where))
  756.     return HR_NOERROR;
  757.  
  758.   // Make sure that the view will accept this drop
  759.   //
  760.   if (!ContainerHost->EvOcViewDrop(dd))
  761.    return HR_FAIL;
  762.  
  763.   // Create part now that view approved. BDocument calls AddSite on all views.
  764.   //
  765.   try {
  766.     new TOcPart(OcDocument, *dd.InitInfo, aobjPos);
  767.   }
  768.   catch (...) {
  769.     return HR_FAIL;
  770.   }
  771.  
  772.   Rename();
  773.  
  774.   return HR_NOERROR;
  775. }
  776.  
  777. //
  778. // Provide feedback to the users drag action in our container window
  779. //
  780. void _IFUNC
  781. TOcView::DragFeedback(TPoint far* where, const TRect far* objPos, TOcMouseAction /*action*/, uint, HRESULT& hr)
  782. {
  783.   PRECONDITION(where && objPos);
  784.  
  785.   TPoint awhere(*where);
  786.   TRect  aobjPos(*objPos);
  787.   TOcDragDrop dd = { 0, &awhere, &aobjPos };
  788.  
  789.   hr = HRFailIfZero(ContainerHost->EvOcViewDrag(dd));
  790. }
  791.  
  792. //
  793. // Ask the container view window to scroll itself in a given direction. Asked
  794. // by the server when dragging or working in a clipped site.
  795. //
  796. HRESULT _IFUNC
  797. TOcView::Scroll(TOcScrollDir scrollDir)
  798. {
  799.   // Have the real view do the work here.
  800.   //
  801.   if (!ContainerHost->EvOcViewScroll(scrollDir))
  802.     return HR_FALSE;
  803.   return HR_NOERROR;
  804. }
  805.  
  806. //
  807. //
  808. //
  809. HRESULT _IFUNC
  810. TOcView::GetScrollRect(TRect far*)
  811. {
  812.   return HR_NOERROR;
  813. }
  814.  
  815. //----------------------------------------------------------------------------
  816. // IBContainer implementation
  817.  
  818. //
  819. // Locate the drop destination object. For default OC, it is just this view.
  820. // Other extensions might have subtargets within the view.
  821. //
  822. HRESULT _IFUNC
  823. TOcView::FindDropDest(TPoint far*, IBDropDest far* far* dropDest)
  824. {
  825.   *dropDest = this;
  826.   return HR_NOERROR;
  827. }
  828.  
  829. //
  830. //
  831. //
  832. HRESULT _IFUNC
  833. TOcView::BringToFront()
  834. {
  835.   // See if we are in an MDI child & if so activate it
  836.   //
  837.   HWND hMdiChild = ::GetParent(GetWindow());
  838.   if (hMdiChild) {
  839.     HWND hMdiClient = ::GetParent(hMdiChild);
  840.     if (hMdiClient) {
  841.       HWND hMdiFrame = ::GetParent(hMdiClient);
  842.       while (::GetParent(hMdiFrame)) {
  843.         hMdiChild = hMdiClient;
  844.         hMdiClient = hMdiFrame;
  845.         hMdiFrame = ::GetParent(hMdiFrame);
  846.       }
  847.       ::SendMessage(hMdiClient, WM_MDIACTIVATE, (WPARAM)hMdiChild, 0);
  848.     }
  849.   }
  850.  
  851.   // Bring our app frame to the top, show it & give it focus. Also make sure
  852.   // that this view is on top & visible
  853.   //
  854.   ::SetWindowPos(OcApp.GetWindow(), HWND_TOP, 0, 0, 0, 0,
  855.                  SWP_NOMOVE|SWP_NOSIZE | SWP_SHOWWINDOW);
  856.   ::SetFocus(OcApp.GetWindow());
  857.   ::ShowWindow(GetWindow(), SW_SHOWNORMAL);
  858.   ::SetWindowPos(GetWindow(), HWND_TOP, 0, 0, 0, 0,
  859.                  SWP_NOMOVE|SWP_NOSIZE | SWP_SHOWWINDOW); // why force a show window?
  860.  
  861.   return HR_NOERROR;
  862. }
  863.  
  864. //
  865. //
  866. //
  867. HRESULT _IFUNC
  868. TOcView::AllowInPlace()
  869. {
  870.   if (IsOptionSet(voNoInPlace))
  871.     return HR_FALSE;
  872.   else
  873.     return HR_NOERROR;
  874. }
  875.  
  876. //----------------------------------------------------------------------------
  877. // Clipboard related
  878.  
  879. //
  880. // Register the clipboard formats supported
  881. //
  882. bool
  883. TOcView::RegisterClipFormats(TRegList& regList)
  884. {
  885.   // Register link source first
  886.   //
  887.   uint cfLinkSource = ::RegisterClipboardFormat("Link Source");
  888.   if (cfLinkSource)
  889.     FormatList.Add(new TOcFormat(cfLinkSource, "%s", "%s",
  890.                                  4 /*BOLE_MED_STREAM*/, true));
  891.  
  892.   char  key[32];
  893.   char  val[128];
  894.   char* buf;
  895.   uint  i = 0;
  896.   bool  succ = true;
  897.  
  898.   while (true) {
  899.     wsprintf(key, "format%d", i);
  900.     buf = const_cast<char*>(regList[key]);
  901.     if (!buf)
  902.       break;
  903.     else {
  904.       // parse the value string
  905.       //
  906.       strcpy(val, buf);
  907.       buf = val;
  908.  
  909.       TOcFormat* format = new TOcFormat;
  910.  
  911.       for (int i = 0; i < 3; i++) {
  912.         char* current = strchr(buf, ',');
  913.         if (!current) {
  914.           succ = false;
  915.           break; // error
  916.         }
  917.  
  918.         *current = 0;
  919.         switch (i) {
  920.           case 0: // Format id or name
  921.             if (isdigit(*buf)) {
  922.               uint id = atoi(buf);
  923.               format->SetFormatId(id);
  924.               format->SetFormatName(id - 1, OcApp);
  925.             }
  926.             else { // register the user defined clipboard format
  927.               uint cf = ::RegisterClipboardFormat(buf);
  928.               if (cf == cfLinkSource)
  929.                 format->SetLinkable();
  930.  
  931.               format->SetFormatId(cf);
  932.               format->SetFormatName(buf, OcApp);
  933.             }
  934.             break;
  935.  
  936.           case 1: // Aspect
  937.             format->SetAspect((uint)atoi(buf));
  938.             break;
  939.  
  940.           case 2:
  941.             format->SetMedium((uint)atoi(buf)); // Storage medium
  942.             format->SetDirection((uint)atoi(current+1)); // Direction
  943.             break;
  944.         } // switch
  945.  
  946.         buf = current + 1;
  947.       } // for
  948.  
  949.       if (succ)
  950.         FormatList.Add(format); // Add to the format list
  951.       else
  952.         delete format;
  953.     } // else
  954.  
  955.     i++;
  956.   } // while
  957.  
  958.   return succ;
  959. }
  960.  
  961. //
  962. //
  963. //
  964. bool
  965. TOcView::BrowseClipboard(TOcInitInfo& initInfo)
  966. {
  967.   return OcApp.BrowseClipboard(initInfo);
  968. }
  969.  
  970. //
  971. // Paste native data into the container
  972. //
  973. bool
  974. TOcView::PasteNative(TOcInitInfo& init, TPoint far* where)
  975. {
  976.   bool result = false;
  977.   if (init.Where == iwHandle && init.How == ihEmbed) {  // Could be native data
  978.     TOcFormat* format = FormatList.Find(init.Handle.DataFormat);
  979.     if (!format) {
  980.       return false;  // Not my native data
  981.     }
  982.  
  983.     TOcFormatData formatData(*format, 0, init.Handle.Data, true, where);
  984.     result = ServerHost->EvOcViewClipData(formatData);
  985.     if (result)
  986.       init.ReleaseDataObject();
  987.   }
  988.  
  989.   return result;
  990. }
  991.  
  992. //
  993. //
  994. //
  995. bool
  996. TOcView::Paste(bool linking)
  997. {
  998.   LinkFormat = linking ? 0 : -1;  // Whether or not to accept a link format
  999.   TOcInitInfo init(this);
  1000.   bool result = OcApp.Paste(init);
  1001.  
  1002.   if (result) {
  1003.     result = PasteNative(init);
  1004.     if (!result)
  1005.       result = ContainerHost->EvOcViewPasteObject(init);
  1006.   }
  1007.  
  1008.   return result;
  1009. }
  1010.  
  1011. //-----------------------------------------------------------------------------
  1012. // TOcFormat
  1013. //
  1014.  
  1015. //
  1016. //
  1017. //
  1018. TOcFormat::TOcFormat()
  1019. {
  1020.   char fstr[] = "%s";
  1021.  
  1022.   Id = 0;
  1023.   RegName[0] = 0;
  1024.   strcpy(Name, fstr);
  1025.   strcpy(ResultName, fstr);
  1026.   Medium     = ocrNull;
  1027.   IsLinkable = false;
  1028.   Aspect     = 1;  // content
  1029.   Direction  = 1;  // get
  1030. }
  1031.  
  1032. //
  1033. //
  1034. //
  1035. TOcFormat::TOcFormat(uint id, char far* name, char far* resultName,
  1036.                      uint medium, bool isLinkable,
  1037.                      uint aspect, uint direction)
  1038. {
  1039.   Id         = (WORD)id;
  1040.   Medium     = (ocrMedium)medium;
  1041.   IsLinkable = isLinkable;
  1042.   Aspect     = aspect;
  1043.   Direction  = direction;
  1044.  
  1045.   RegName[0] = 0;
  1046.   strcpy(Name, name);
  1047.   strcpy(ResultName, resultName);
  1048. }
  1049.  
  1050. //
  1051. //
  1052. //
  1053. void
  1054. TOcFormat::operator =(const TOcFormatInfo& f)
  1055. {
  1056.   Id = f.Id;
  1057.   strcpy(Name, OleStr(f.Name));
  1058.   strcpy(ResultName, OleStr(f.ResultName));
  1059.   Medium = f.Medium;
  1060.   IsLinkable = f.IsLinkable;
  1061. }
  1062.  
  1063. //
  1064. //
  1065. //
  1066. void
  1067. TOcFormat::GetFormatInfo(TOcFormatInfo far& f)
  1068. {
  1069.   f.Id = uint16(Id);
  1070. #if defined(BI_OLECHAR_WIDE)
  1071. //  lstrcpyW(f.Name, OleStr(Name));
  1072.   memcpy(f.Name, (LPCWSTR)OleStr(Name), (strlen(Name)+1)*2);
  1073. // lstrcpyW(f.ResultName, OleStr(ResultName));
  1074.   memcpy(f.ResultName, (LPCWSTR)OleStr(ResultName), (strlen(ResultName)+1)*2);
  1075. #else
  1076.   strncpy(f.Name, Name, sizeof Name);
  1077.   strncpy(f.ResultName, ResultName, sizeof ResultName);
  1078. #endif
  1079.   f.Medium = (ocrMedium)Medium;
  1080.   f.IsLinkable = (BOOL)IsLinkable;
  1081. }
  1082.  
  1083. //
  1084. //
  1085. //
  1086. void
  1087. TOcFormat::SetFormatName(char far* name, TOcApp& ocApp)
  1088. {
  1089.   TOcFormatName* formatName = ocApp.GetNameList()[name];
  1090.   if (!formatName)
  1091.     return;
  1092.  
  1093.   strcpy(RegName, name);
  1094.   strcpy(Name, formatName->GetName());
  1095.   strcpy(ResultName, formatName->GetResultName());
  1096. }
  1097.  
  1098. //
  1099. //
  1100. //
  1101. void
  1102. TOcFormat::SetFormatName(uint id, TOcApp& ocApp)
  1103. {
  1104.   TOcFormatName* formatName = ocApp.GetNameList()[id];
  1105.   if (!formatName)
  1106.     return;
  1107.  
  1108.   strcpy(Name, formatName->GetName());
  1109.   strcpy(ResultName, formatName->GetResultName());
  1110. }
  1111.  
  1112.  
  1113. //----------------------------------------------------------------------------
  1114. // TOcFormatList
  1115. //
  1116.  
  1117. //
  1118. //
  1119. //
  1120. TOcFormatList::TOcFormatList()
  1121. :
  1122.   TICVectorImp<TOcFormat>(10, 0)
  1123. {
  1124. }
  1125.  
  1126. //
  1127. //
  1128. //
  1129. TOcFormatList::~TOcFormatList()
  1130. {
  1131.   Clear();
  1132. }
  1133.  
  1134. //
  1135. //
  1136. //
  1137. TOcFormat*
  1138. TOcFormatList::Find(uint const id) const
  1139. {
  1140.   for (TOcFormatListIter j(*this); j; j++) {
  1141.     TOcFormat* format = (TOcFormat*)j.Current();
  1142.     if (format && format->GetFormatId() == id) {
  1143.       return format;
  1144.     }
  1145.   }
  1146.  
  1147.   return 0;
  1148. }
  1149.  
  1150.  
  1151. //----------------------------------------------------------------------------
  1152. // TOcSiteRect
  1153. //
  1154.  
  1155. TOcSiteRect::TOcSiteRect()
  1156. :
  1157.   Rect(0,0,0,0), Part(0)
  1158. {
  1159. }
  1160.  
  1161. TOcSiteRect::TOcSiteRect(TOcPart *part, const TRect& rect)
  1162. :
  1163.   Rect(rect), Part(part)
  1164. {
  1165. }
  1166.  
  1167. //----------------------------------------------------------------------------
  1168. // TOcScaleFactor
  1169. //
  1170.  
  1171. //
  1172. //
  1173. //
  1174. TOcScaleFactor::TOcScaleFactor()
  1175. :
  1176.   SiteSize(1, 1),
  1177.   PartSize(1, 1)
  1178. {
  1179. }
  1180.  
  1181. //
  1182. //
  1183. //
  1184. TOcScaleFactor::TOcScaleFactor(const TRect& siteRect, const TSize& partSize)
  1185. {
  1186.   SiteSize.cx = siteRect.Width();
  1187.   SiteSize.cy = siteRect.Height();
  1188.  
  1189.   PartSize = partSize;
  1190. }
  1191.  
  1192. //
  1193. //
  1194. //
  1195. TOcScaleFactor::TOcScaleFactor(const TOcScaleInfo far& scale)
  1196. {
  1197.   *this = scale;
  1198. }
  1199.  
  1200. //
  1201. // Assign a BOle structure to this scale factor
  1202. //
  1203. TOcScaleFactor&
  1204. TOcScaleFactor::operator =(const TOcScaleInfo far& scaleInfo)
  1205. {
  1206.   SiteSize.cx = (int)scaleInfo.xN;
  1207.   SiteSize.cy = (int)scaleInfo.yN;
  1208.   PartSize.cx = (int)scaleInfo.xD;
  1209.   PartSize.cy = (int)scaleInfo.yD;
  1210.  
  1211.   return *this;
  1212. }
  1213.  
  1214. //
  1215. // Assign one TOcScaleFactor to another
  1216. //
  1217. TOcScaleFactor&
  1218. TOcScaleFactor::operator =(const TOcScaleFactor& scaleFactor)
  1219. {
  1220.   SiteSize = scaleFactor.SiteSize;
  1221.   PartSize = scaleFactor.PartSize;
  1222.  
  1223.   return *this;
  1224. }
  1225.  
  1226. //
  1227. // Copy a BOle scale factor structure
  1228. //
  1229. void
  1230. TOcScaleFactor::GetScaleFactor(TOcScaleInfo far& scaleInfo) const
  1231. {
  1232.   scaleInfo.xN = SiteSize.cx;
  1233.   scaleInfo.yN = SiteSize.cy;
  1234.   scaleInfo.xD = PartSize.cx;
  1235.   scaleInfo.yD = PartSize.cy;
  1236. }
  1237.  
  1238. //
  1239. // Whether there is zoom factor
  1240. //
  1241. bool
  1242. TOcScaleFactor::IsZoomed()
  1243. {
  1244.   return SiteSize != PartSize;
  1245. }
  1246.  
  1247. //
  1248. // Change the scaling factor
  1249. //
  1250. void
  1251. TOcScaleFactor::SetScale(uint16 percent)
  1252. {
  1253.   PartSize.cx = PartSize.cy = 100;
  1254.   SiteSize.cx = SiteSize.cy = percent;
  1255. }
  1256.  
  1257. //
  1258. // Get the scale percentage
  1259. //
  1260. uint16
  1261. TOcScaleFactor::GetScale()
  1262. {
  1263.   return (uint16)(((uint32)SiteSize.cx * 100 + (PartSize.cx >> 1)) / PartSize.cx);
  1264. }
  1265.  
  1266. //
  1267. // Set scaling factor to 1
  1268. //
  1269. void
  1270. TOcScaleFactor::Reset()
  1271. {
  1272.   PartSize.cx = PartSize.cy = 1;
  1273.   SiteSize.cx = SiteSize.cy = 1;
  1274. }
  1275.  
  1276. //----------------------------------------------------------------------------
  1277.  
  1278. bool
  1279. TOcContainerHostMsg::EvOcViewOpenDoc(const char far* path)
  1280. {
  1281.   return (bool)ForwardEvent(OC_VIEWOPENDOC, path);
  1282. }
  1283.  
  1284. const char far*
  1285. TOcContainerHostMsg::EvOcViewTitle()
  1286. {
  1287.   return (const char far*)ForwardEvent(OC_VIEWTITLE);
  1288. }
  1289.  
  1290. void
  1291. TOcContainerHostMsg::EvOcViewSetTitle(const char far* title)
  1292. {
  1293.   ForwardEvent(OC_VIEWSETTITLE, title);
  1294. }
  1295.  
  1296. bool
  1297. TOcContainerHostMsg::EvOcViewBorderSpaceReq(const TRect far* space)
  1298. {
  1299.   return (bool)ForwardEvent(OC_VIEWBORDERSPACEREQ, space);
  1300. }
  1301.  
  1302. bool
  1303. TOcContainerHostMsg::EvOcViewBorderSpaceSet(const TRect far* space)
  1304. {
  1305.   return (bool)ForwardEvent(OC_VIEWBORDERSPACESET, space);
  1306. }
  1307.  
  1308. bool
  1309. TOcContainerHostMsg::EvOcViewDrag(TOcDragDrop far& ddInfo)
  1310. {
  1311.   return (bool)ForwardEvent(OC_VIEWDRAG, &ddInfo);
  1312. }
  1313.  
  1314. bool
  1315. TOcContainerHostMsg::EvOcViewDrop(TOcDragDrop far& ddInfo)
  1316. {
  1317.   return (bool)ForwardEvent(OC_VIEWDROP, &ddInfo);
  1318. }
  1319.  
  1320. bool
  1321. TOcContainerHostMsg::EvOcViewScroll(TOcScrollDir scrollDir)
  1322. {
  1323.   return (bool)ForwardEvent(OC_VIEWSCROLL, scrollDir);
  1324. }
  1325.  
  1326. bool
  1327. TOcContainerHostMsg::EvOcPartInvalid(TOcPartChangeInfo& changeInfo)
  1328. {
  1329.   return (bool)ForwardEvent(OC_VIEWPARTINVALID, &changeInfo);
  1330. }
  1331.  
  1332. bool
  1333. TOcContainerHostMsg::EvOcViewPasteObject(TOcInitInfo& init)
  1334. {
  1335.   return (bool)ForwardEvent(OC_VIEWPASTEOBJECT, &init);
  1336. }
  1337.  
  1338. bool
  1339. TOcContainerHostMsg::EvOcViewGetSiteRect(TOcSiteRect& sr)
  1340. {
  1341.   return (bool)ForwardEvent(OC_VIEWGETSITERECT, &sr);
  1342. }
  1343.  
  1344. bool
  1345. TOcContainerHostMsg::EvOcViewSetSiteRect(TOcSiteRect& sr)
  1346. {
  1347.   return (bool)ForwardEvent(OC_VIEWSETSITERECT, &sr);
  1348. }
  1349.  
  1350. bool
  1351. TOcContainerHostMsg::EvOcViewPartActivate(TOcPart& ocPart)
  1352. {
  1353.   return (bool)ForwardEvent(OC_VIEWPARTACTIVATE, &ocPart);
  1354. }
  1355.  
  1356. bool
  1357. TOcContainerHostMsg::EvOcViewGetScale(TOcScaleFactor& scaleFactor)
  1358. {
  1359.   return (bool)ForwardEvent(OC_VIEWGETSCALE, &scaleFactor);
  1360. }
  1361.  
  1362. //
  1363. //
  1364. //
  1365. uint32
  1366. TOcContainerHostMsg::ForwardEvent(int eventId, const void far* param)
  1367. {
  1368.   return ::SendMessage(EvOcGetWindow(), WM_OCEVENT, eventId, (LPARAM)param);
  1369. }
  1370.  
  1371. //
  1372. //
  1373. //
  1374. uint32
  1375. TOcContainerHostMsg::ForwardEvent(int eventId, uint32 param)
  1376. {
  1377.   return ::SendMessage(EvOcGetWindow(), WM_OCEVENT, eventId, param);
  1378. }
  1379.  
  1380. //----------------------------------------------------------------------------
  1381.  
  1382. bool
  1383. TOcServerHostMsg::EvOcViewGetItemName(TOcItemName& item)
  1384. {
  1385.   return (bool)ForwardEvent(OC_VIEWGETITEMNAME, &item);
  1386. }
  1387.  
  1388. bool
  1389. TOcServerHostMsg::EvOcViewClipData(TOcFormatData far& formatData)
  1390. {
  1391.   return (bool)ForwardEvent(OC_VIEWCLIPDATA, &formatData);
  1392. }
  1393.  
  1394. bool
  1395. TOcServerHostMsg::EvOcViewSetData(TOcFormatData far& formatData)
  1396. {
  1397.   return (bool)ForwardEvent(OC_VIEWSETDATA, &formatData);
  1398. }
  1399.  
  1400. bool
  1401. TOcServerHostMsg::EvOcViewPartSize(TOcPartSize far& ps)
  1402. {
  1403.   return (bool)ForwardEvent(OC_VIEWPARTSIZE, &ps);
  1404. }
  1405.  
  1406. bool
  1407. TOcServerHostMsg::EvOcViewSavePart(TOcSaveLoad far& ocSave)
  1408. {
  1409.   return (bool)ForwardEvent(OC_VIEWSAVEPART, &ocSave);
  1410. }
  1411.  
  1412. bool
  1413. TOcServerHostMsg::EvOcViewPaint(TOcViewPaint far& vp)
  1414. {
  1415.   return (bool)ForwardEvent(OC_VIEWPAINT, &vp);
  1416. }
  1417.  
  1418. bool
  1419. TOcServerHostMsg::EvOcViewAttachWindow(bool attach)
  1420. {
  1421.   return (bool)ForwardEvent(OC_VIEWATTACHWINDOW, attach);
  1422. }
  1423.  
  1424. void
  1425. TOcServerHostMsg::EvOcViewSetTitle(const char far* title)
  1426. {
  1427.   ForwardEvent(OC_VIEWSETTITLE, title);
  1428. }
  1429.  
  1430. bool
  1431. TOcServerHostMsg::EvOcViewDrag(TOcDragDrop far& ddInfo)
  1432. {
  1433.   return (bool)ForwardEvent(OC_VIEWDRAG, &ddInfo);
  1434. }
  1435.  
  1436. bool
  1437. TOcServerHostMsg::EvOcViewSetLink(TOcLinkView& linkView)
  1438. {
  1439.   return (bool)ForwardEvent(OC_VIEWSETLINK, &linkView);
  1440. }
  1441.  
  1442. bool
  1443. TOcServerHostMsg::EvOcViewBreakLink(TOcLinkView& linkView)
  1444. {
  1445.   return (bool)ForwardEvent(OC_VIEWBREAKLINK, &linkView);
  1446. }
  1447.  
  1448. bool
  1449. TOcServerHostMsg::EvOcViewGetPalette(LOGPALETTE far* far* palette)
  1450. {
  1451.   return (bool)ForwardEvent(OC_VIEWGETPALETTE, palette);
  1452. }
  1453.  
  1454. bool
  1455. TOcServerHostMsg::EvOcViewLoadPart(TOcSaveLoad far& ocLoad)
  1456. {
  1457.   return (bool)ForwardEvent(OC_VIEWLOADPART, &ocLoad);
  1458. }
  1459.  
  1460. bool
  1461. TOcServerHostMsg::EvOcViewInsMenus(TOcMenuDescr far& sharedMenu)
  1462. {
  1463.   return (bool)ForwardEvent(OC_VIEWINSMENUS, &sharedMenu);
  1464. }
  1465.  
  1466. bool
  1467. TOcServerHostMsg::EvOcViewShowTools(TOcToolBarInfo far& tbi)
  1468. {
  1469.   return (bool)ForwardEvent(OC_VIEWSHOWTOOLS, &tbi);
  1470. }
  1471.  
  1472. bool
  1473. TOcServerHostMsg::EvOcViewClose()
  1474. {
  1475.   return (bool)ForwardEvent(OC_VIEWCLOSE);
  1476. }
  1477.  
  1478. bool
  1479. TOcServerHostMsg::EvOcViewSetScale(TOcScaleFactor& scaleFactor)
  1480. {
  1481.   return (bool)ForwardEvent(OC_VIEWSETSCALE, &scaleFactor);
  1482. }
  1483.  
  1484. bool
  1485. TOcServerHostMsg::EvOcViewDoVerb(uint verb)
  1486. {
  1487.   return (bool)ForwardEvent(OC_VIEWDOVERB, verb);
  1488. }
  1489.  
  1490. //
  1491. //
  1492. //
  1493. uint32
  1494. TOcServerHostMsg::ForwardEvent(int eventId, const void far* param)
  1495. {
  1496.   return ::SendMessage(EvOcGetWindow(), WM_OCEVENT, eventId, (LPARAM)param);
  1497. }
  1498.  
  1499. //
  1500. //
  1501. //
  1502. uint32
  1503. TOcServerHostMsg::ForwardEvent(int eventId, uint32 param)
  1504. {
  1505.   return ::SendMessage(EvOcGetWindow(), WM_OCEVENT, eventId, param);
  1506. }
  1507.